<?php

class Quad_Form_Fieldset extends Quad_Form {

	protected $_form;
	
	public function __construct(Quad_Form $form) {
		$this->_form = $form;
		parent::__construct(array());		
		$this->_tagName = 'fieldset';
	}
	
	public function __toString() {
		$this->_tagName = 'div';
		
		$html = $this->getOpenTag();
		$html .= '<fieldset class="q-fieldset">';
		if (is_string($this->h3)) {
			$html .= "<h3><span>$this->h3</span></h3>";
		}
		elseif (is_string($this->legend)) {
			$html .= "<legend><span>$this->h3</span></legend>";
		}
		$html .= $this->getElementsHtml();
		$html .= '</fieldset>';
		$html .= $this->getCloseTag();
		
		$this->_tagName = 'fieldset';
		$html = $this->_applyDecorators($html);
		return $html;
	}
    
}
